package com.zyw.security.shiro.web.authc.tk;

import org.apache.shiro.authc.RememberMeAuthenticationToken;

/**
 * 普通的 username password 登录token
 *
 * @author zhangyw
 * @date 2018/1/25 9:39
 */
public class FormAuthcToken extends BasicAuthcToken implements RememberMeAuthenticationToken {

    /**
     * The username
     */
    private String username;

    /**
     * The password, in char[] format
     */
    private String password;

    /**
     * Whether or not 'rememberMe' should be enabled for the corresponding login attempt;
     * default is <code>false</code>
     */
    private boolean rememberMe = false;

    public FormAuthcToken() {
    }

    public FormAuthcToken(String username, String password) {
        this(username, password, false, null);
    }

    public FormAuthcToken(String username, String password, boolean rememberMe) {
        this(username, password, rememberMe, null);
    }

    public FormAuthcToken(String username, String password, boolean rememberMe, String host) {
        this.username = username;
        this.password = password;
        this.rememberMe = rememberMe;
        this.setHost(host);
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setRememberMe(boolean rememberMe) {
        this.rememberMe = rememberMe;
    }

    @Override
    public boolean isRememberMe() {
        return false;
    }

    @Override
    public Object getPrincipal() {
        return getUsername();
    }

    @Override
    public Object getCredentials() {
        return getPassword();
    }


}
